<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="java.util.List"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <script type="text/javascript">
            function check1() {
                if (document.ff1.keyword.value == "") {
                    alert("请输入用户信息！");
                    return false;
                }
                return true;
            }
            function check2() {
                if (document.ff2.keyword.value == "") {
                    alert("请输入图书信息！");
                    return false;
                }
                return true;
            }
        </script>
    </head>
    <body>
        <div class="container">
            <h1 class="text-primary text-center">管理界面</h1>
            <div style="position:absolute;right:200px;top:10px">
                <h3><a href="index">退出</a></h3>
            </div>
            <br><br>
            <h3 class="text-success">用户列表</h3>

            <form name="ff1"   action="UserSearchResult.jsp" onsubmit="return check1()">
                <div class="col-lg-6" style="width:500px">
                    <div class="input-group">
                        <input type="text" class="form-control" name="keyword" >
                        <span class="input-group-btn">
                            <button class="btn btn-default">搜索用户信息</button>
                        </span>
                    </div>
                </div>
            </form><br><br>


            <%
                List<Member> list = new MemberDao().getAllMember();
            %>
            <table class="table table-condensed table-striped" style="width: 500px">
                <tr><th>姓名</th><th>性别</th><th>手机号</th><th></th><th></th></tr>
                        <%
                            for (int j = list.size() - 1; j >= 0; j--) {
                        %>
                <tr><td><%=list.get(j).getName()%></td><td><%=list.get(j).getGender()%></td>
                    <td><%=list.get(j).getPhone()%></td>
                    <td><a href="MemberInfo.jsp?userid=<%=list.get(j).getId()%>">查看详情</a></td>
                    <%
                        if (list.get(j).getIsForbid() == false) {
                    %>
                    <td><a href="fus?userid=<%=list.get(j).getId()%>&type=1">禁用此用户</a></td></tr>
                    <%
                    } else {
                    %>
                <td><a href="fus?userid=<%=list.get(j).getId()%>&type=2">解禁用户</a></td></tr>

                <%
                        }
                    }
                %>

            </table>
            <br><br>
            <h3 class="text-success">图书列表</h3>
            <h4><a href="AddBook.jsp">添加图书信息</a></h4>
            <form name="ff2"   action="SearchBookInfoResult.jsp" onsubmit="return check2()">
                <div class="col-lg-6" style="width:500px">
                    <div class="input-group">
                        <input type="text" class="form-control" name="keyword" >
                        <span class="input-group-btn">
                            <button class="btn btn-default">搜索图书信息</button>
                        </span>
                    </div>
                </div>
            </form><br><br>

            <br>
            <table class="table table-condensed table-striped" style="width: 900px"> 
                <tr><th>书名</th><th>作者</th><th>出版社</th><th>编号</th><th>类型</th><th></th><th></th><th></th></tr>
                        <%
                            List<Book> list1 = new BookDao().getAllUndeletedBook();
                            for (int i = list1.size() - 1; i >= 0; i--) {
                        %>
                <tr><td><%=list1.get(i).getBookName()%></td><td><%=list1.get(i).getAuthor()%></td><td><%=list1.get(i).getPublishHouse()%></td><td><%=list1.get(i).getId()%></td><td><%=list1.get(i).getType()%></td>
                    <td><a href="BookInfo.jsp?bookid=<%=list1.get(i).getId()%>" target="_blank">查看详情</a></td>
                    <td><a href="AddImage.jsp?bookid=<%=list1.get(i).getId()%>">添加图片</a></td>
                    <td><a href="ModifyBook.jsp?bookid=<%=list1.get(i).getId()%>">修改图书</a></td>
                    <td><a href="dbs?bookid=<%=list1.get(i).getId()%>">删除图书</a></td></tr>
                    <%
                        }
                    %></table>
        </div>
    </body>
</html>
